package com.itheima.manager.web;

import com.itheima.manager.pojo.Contact;
import com.itheima.manager.service.ISelectByIdService;
import com.itheima.manager.service.imp.SelectByIdServiceImp;
import com.itheima.manager.service.imp.SelectByNameServiceImp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(name = "LimtServlet", value = "/LimtServlet")
public class LimtServlet extends HttpServlet {
    private SelectByNameServiceImp selectByNameServiceImp = new SelectByNameServiceImp();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String name = request.getParameter("name");
        String min = request.getParameter("min");
        String max = request.getParameter("max");
        String size = request.getParameter("size");


        Map<String,String> map = new HashMap<>();
        map.put("name",name);
        map.put("min",min);
        map.put("max",max);
        map.put("size",size);


        List<Contact> contact1 = selectByNameServiceImp.selectLink(map);
        List<Contact> contact2 = selectByNameServiceImp.selectLimit(map);

        request.setAttribute("contacts",contact1);
        request.setAttribute("contact2",contact2);
        request.getRequestDispatcher("list.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
